
//客户端域名
var webUrl = 'http://localhost:8090';

//服务端域名
var serverUrl = 'http://localhost:8091';

//SSO域名
var ssoUrl = 'http://localhost:8888';

//SSO注销地址
var ssoLogout = ssoUrl + '/sso/logout?callBackUrl=' + webUrl;

//服务支持邮箱
var supportMail = '1191837698@qq.com';

//设置全局AJAX配置（跨域支持,携带cookie）
$.ajaxSetup({
    xhrFields: {
        withCredentials: true
    },
    crossDomain: true,
});

// 常规浏览器语言和IE浏览器
String.prototype.orEnglish = function (en) {
    var lang = navigator.language || navigator.userLanguage;
    lang = lang.substr(0, 2);
    return (lang === 'zh') ? this.toString() : en;
};

// 跳转页面
function jumpToURL(URL) {
    window.location.href = URL;
}

// 这个接口用来保存永久数据(localStorage)
function saveData(key, value) {
    localStorage.setItem(key, JSON.stringify({ value: value }));
}

function loadData(key) {
    var data = localStorage.getItem(key);
    return data ? JSON.parse(data).value : null;
}

// 这个接口用来保存临时数据，浏览器关闭时会清空(sessionStorage)
function saveCache(key, value) {
    sessionStorage.setItem(key, JSON.stringify({ value: value }));
}

function loadCache(key) {
    var data = sessionStorage.getItem(key);
    return data ? JSON.parse(data).value : null;
}

//翻译数字
function getSequence(num) {
    if (isNaN(num)) {
        return num;
    }
    return (num == 1) ? '1st' : (num == 2) ? '2nd' : (num == 3) ? '3rd' : (num > 3) ? (num + 1) + 'th' : num;
}